package com.kaka.bus.engine.evaluate;

import com.kaka.bus.bean.HttpWrapper;
import com.kaka.bus.di.DataManager;
import com.kaka.bus.manager.Result;
import com.kaka.bus.manager.T;
import com.kaka.bus.mvp.RxPresenter;

import javax.inject.Inject;

/**
 * Created by OnionMac on 2018/1/16.
 */

public class EvaluatePresenter extends RxPresenter<EvaluateContract.View> implements EvaluateContract.Presenter{

    @Inject
    public EvaluatePresenter(DataManager dataManager) {
        super(dataManager);
    }

    @Override
    public void commitPhoneInfo(String userId, String platform, String sequence, String phoneInfo) {
        mView.showDialog("评估设备中..");
        addSubscribe(mDataManager
                .getApi()
                .commitPhoneInfo(userId,phoneInfo,platform,sequence)
                .compose(T.D())
                .subscribeWith(new Result<HttpWrapper<String>>() {
                    @Override
                    protected void onSuccess(HttpWrapper<String> wrapper) {
                        mView.commitSuccess(wrapper);
                    }

                    @Override
                    protected void onFinish() {
                        super.onFinish();
                        mView.dissDialog();
                    }
                }));
    }
}
